package com.liming.dao;

import java.sql.SQLException;
import java.util.List;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import com.liming.model.Comment;
import com.liming.model.Orders;
import com.liming.utils.DataSourceUtils;

public class Commentdao {
	QueryRunner qr = new QueryRunner(DataSourceUtils.getDataSource());

	public List<Comment> getAllComment(int goodsid) {
		
		List<Comment> comments = null;
		
		String sql = "Select * from comment where goodsid = ?";
		try {
			comments = qr.query(sql, new BeanListHandler<>(Comment.class),goodsid);
			if (comments.size()==0||comments==null) {
				return null;
			}
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		return comments;
	}
	
	
}
